package com.ruoyi.labdata.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.labdata.domain.LabGasCylinderNumber;
import com.ruoyi.labdata.domain.LabGasCylindersType;
import com.ruoyi.labdata.service.ILabGasCylinderNumberService;
import com.ruoyi.labdata.service.ILabGasCylindersTypeService;

/**
 * 危化气瓶数量Controller
 * 
 * @author winner pan
 * @date 2022-02-07
 */
@RestController
@RequestMapping("/labdata/gasCylinderNum")
public class LabGasCylinderNumberController extends BaseController {
	@Autowired
	private ILabGasCylinderNumberService labGasCylinderNumberService;

	@Autowired
	private ILabGasCylindersTypeService labGasCylindersTypeService;

	@GetMapping(value = "/allGasCylindersType")
	public AjaxResult getAllGasCylindersType() {
		LabGasCylindersType labGasCylindersType = new LabGasCylindersType();
		labGasCylindersType.setKindsId(Long.valueOf(3));
		labGasCylindersType.setStatusOpt(Long.valueOf(1));
		return AjaxResult.success(labGasCylindersTypeService.selectLabGasCylindersTypeList(labGasCylindersType));
	}

	/**
	 * 查询危化气瓶数量列表
	 */
	//@PreAuthorize("@ss.hasPermi('labdata:gasCylinderNum:query')")
	@GetMapping("/list")
	public TableDataInfo list(LabGasCylinderNumber labGasCylinderNumber) {
		startPage();
		List<LabGasCylinderNumber> list = labGasCylinderNumberService
				.selectLabGasCylinderNumberList(labGasCylinderNumber);
		return getDataTable(list);
	}

	/**
	 * 导出危化气瓶数量列表
	 */
	// @PreAuthorize("@ss.hasPermi('labdata:gasCylinderNum:export')")
	/*
	 * @Log(title = "危化气瓶数量", businessType = BusinessType.EXPORT)
	 * 
	 * @GetMapping("/export") public AjaxResult export(LabGasCylinderNumber
	 * labGasCylinderNumber) { List<LabGasCylinderNumber> list =
	 * labGasCylinderNumberService.selectLabGasCylinderNumberList(
	 * labGasCylinderNumber); ExcelUtil<LabGasCylinderNumber> util = new
	 * ExcelUtil<LabGasCylinderNumber>(LabGasCylinderNumber.class); return
	 * util.exportExcel(list, "gasCylinderNum"); }
	 */

	/**
	 * 获取危化气瓶数量详细信息
	 */
	@PreAuthorize("@ss.hasPermi('labdata:gasCylinderNum:query')")
	@GetMapping(value = "/{cylinderNumberId}")
	public AjaxResult getInfo(@PathVariable("cylinderNumberId") Long cylinderNumberId) {
		return AjaxResult.success(labGasCylinderNumberService.selectLabGasCylinderNumberById(cylinderNumberId));
	}

	/**
	 * 新增危化气瓶数量
	 */
	@PreAuthorize("@ss.hasPermi('labdata:gasCylinderNum:edit')")
	@Log(title = "危化气瓶数量", businessType = BusinessType.INSERT)
	@PostMapping
	public AjaxResult add(@RequestBody LabGasCylinderNumber[] labGasCylinderNumber) {
		return toAjax(labGasCylinderNumberService.insertLabGasCylinderNumber(labGasCylinderNumber));
	}

	/**
	 * 修改危化气瓶数量
	 */
	@PreAuthorize("@ss.hasPermi('labdata:gasCylinderNum:edit')")
	@Log(title = "危化气瓶数量", businessType = BusinessType.UPDATE)
	@PutMapping
	public AjaxResult edit(@RequestBody LabGasCylinderNumber labGasCylinderNumber) {
		return toAjax(labGasCylinderNumberService.updateLabGasCylinderNumber(labGasCylinderNumber));
	}

	/**
	 * 删除危化气瓶数量
	 */
	@PreAuthorize("@ss.hasPermi('labdata:gasCylinderNum:edit')")
	@Log(title = "危化气瓶数量", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cylinderNumberIds}")
	public AjaxResult remove(@PathVariable Long[] cylinderNumberIds) {
		return toAjax(labGasCylinderNumberService.deleteLabGasCylinderNumberByIds(cylinderNumberIds));
	}
}
